<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr = [1, 2, 3, 4, 5, 6, 7];
    //   let ane = 0;
    //   arr.forEach((v) => {
    //     ane += v;
    //   });
    //   console.log(ane);
    arr.reduce((next,prev,index,arr )=>{
        //next 当前值
        //prev 上一次的值
        //index 下标
        //arr 原数组
        console.log(next);
        return next+prev
    },0)
    </script>
  </body>
</html>
